package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.activity.ClubPostActivity;
import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.ClubCollectBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.PClubCollectViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by NEUSOFT on 2017/10/19.
 */

public class PClubCollectAdapter extends BaseListAdapter {
    public PClubCollectAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView=layoutInflater.inflate(R.layout.item_pclub_collect,parent,false);
        PClubCollectViewHolder holder=new PClubCollectViewHolder(itemView);
        return holder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        PClubCollectViewHolder pClubCollectViewHolder=(PClubCollectViewHolder) holder;
        final ClubCollectBean clubCollectBean = (ClubCollectBean)data.get(position);
        final  int clubId=clubCollectBean.getC_id();
        final String clubname =clubCollectBean.getC_name();
        String clubphone=clubCollectBean.getC_phone();
        String clubtime=clubCollectBean.getC_time();
        final String clubPic = BASE_URI+"clubphoto/"+clubCollectBean.getC_pic();
        pClubCollectViewHolder.clubNameView.setText(clubname);
        pClubCollectViewHolder.clubPhoneView.setText(clubphone);
        pClubCollectViewHolder.clubTimeView.setText(clubtime);
        Picasso.with(context)
                .load(clubPic)
                .placeholder(R.drawable.ic_club)
                .error(R.drawable.ic_noclub)
                .into(pClubCollectViewHolder.imageView);


        //跳转到帖子列表
        pClubCollectViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, ClubPostActivity.class);
                intent.putExtra("c_id",clubCollectBean.getC_id());
                intent.putExtra("c_name",clubCollectBean.getC_name());
                context.startActivity(intent);
            }
        });
    }

}
